package com.ctshk.sapp.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.system.dto.MainDataPaymentRefundTypeDTO;
import com.ctshk.rpc.system.req.*;
import com.ctshk.rpc.system.service.IMainDataPaymentRefundTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 收款退款方式表 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-16
 */
@Api(value = "主數據收款退款方式",tags = "主數據收款退款方式")
@RestController
@RequestMapping("/main/data/payment/refund/type")
public class MainDataPaymentRefundTypeController extends BaseController {

    @DubboReference
    private IMainDataPaymentRefundTypeService mainDataPaymentRefundTypeService;

    /**
     * 新增收款/退款方式
     * @param req
     * @return
     */
    @ApiOperation(value="新增收款退款方式", notes="新增收款退款方式")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增收款/退款方式", operDesc = "新增收款/退款方式")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataPaymentRefundTypeReq req){
        return mainDataPaymentRefundTypeService.add(req,getCurrentUser(getRequest()));
    }
    /**
     * 編輯收款/退款方式
     * @param req
     * @return
     */
    @ApiOperation(value="編輯收款退款方式", notes="編輯收款退款方式")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "編輯收款/退款方式", operDesc = "編輯收款/退款方式")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataPaymentRefundTypeReq req){
        return mainDataPaymentRefundTypeService.update(req,getCurrentUser(getRequest()));
    }

    /**
     * 查詢收款/退款方式
     * @param req
     * @return
     */
    @ApiOperation(value="查看收款退款方式", notes="查看收款退款方式")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看收款/退款方式", operDesc = "查看收款/退款方式")
    @PostMapping("/query")
    public Result<MainDataPaymentRefundTypeDTO> query(@RequestBody @Valid MainDataPaymentRefundTypeIdReq req){
        return Result.success(mainDataPaymentRefundTypeService.query(req));
    }

    /**
     * 查詢收款/退款方式列表
     * @param req
     * @return
     */
    @ApiOperation(value="查看收款退款方式列表", notes="查看收款退款方式列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "查看收款/退款方式列表", operDesc = "查看收款/退款方式列表")
    @PostMapping("/list")
    public Result<PageResponse<MainDataPaymentRefundTypeDTO>> list(@RequestBody @Valid MainDataPaymentRefundTypeListReq req){
        return Result.success(mainDataPaymentRefundTypeService.list(req));
    }

}
